package com.sxbbc.common.core.service.impl;

import com.sxbbc.common.basics.utils.richText.HtmlUtil;
import com.sxbbc.common.core.entity.jz.SysEssay;
import com.sxbbc.common.core.mapper.jz.SysEssayMapper;
import com.sxbbc.common.core.service.ISysEssayService;
import com.sxbbc.common.core.utils.BasePage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商学院 服务实现类
 * </p>
 *
 * @author xiaoky
 * @since 2019-06-11
 */
@Service
public class SysEssayServiceImpl extends ServiceImpl<SysEssayMapper, SysEssay> implements ISysEssayService {

	@Override
	public IPage<SysEssay> queryEssay(BasePage<SysEssay> page, SysEssay essay) {
		QueryWrapper<SysEssay> queryWrapper = new QueryWrapper<SysEssay>();
		if (!StringUtils.isEmpty(essay.getTitle())) {
			queryWrapper.like("title", essay.getTitle());
		}
		IPage<SysEssay> pageInfo = super.page(page, queryWrapper);
		for (SysEssay e : pageInfo.getRecords()) {
			e.setContent(HtmlUtil.getHtmlStr(e.getContent()));
		}
		return pageInfo;
	}

}
